﻿using SWEN3Application.Classes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SWEN3Application
{
    public partial class UserAccountManagement : MasterForm
    {
        public UserAccountManagement()
        {
            InitializeComponent();
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            UserAccount ua = new UserAccount(tbxUsername.Text, tbxPassword.Text, Convert.ToInt32(tbxUserLevel.Text), tbxEmail.Text);
            GeneralModuleDBManager gm = new GeneralModuleDBManager();
            if (gm.createUserAccount(ua) == 0)
            {
                label5.Text = "Cannot Create!";
            }
            else
            {
                label5.Text = "Account is already Created!";
            }
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            GeneralModuleDBManager gm = new GeneralModuleDBManager();
            if (gm.DeleteUserAccount(cbUserName.Text) == 1)
            {
                UserAccountManagement uam = new UserAccountManagement();
                uam.Show();
                this.Hide();      
            }          
        }

        private void UserAccountManagement_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'sWEN3DatabaseSystemDataSet8.UserAccount' table. You can move, or remove it, as needed.
            this.userAccountTableAdapter2.Fill(this.sWEN3DatabaseSystemDataSet8.UserAccount);
            // TODO: This line of code loads data into the 'sWEN3DatabaseSystemDataSet5.UserAccount' table. You can move, or remove it, as needed.
            this.userAccountTableAdapter1.Fill(this.sWEN3DatabaseSystemDataSet5.UserAccount);
            // TODO: This line of code loads data into the 'sWEN3DatabaseSystemDataSet4.UserAccount' table. You can move, or remove it, as needed.
            this.userAccountTableAdapter.Fill(this.sWEN3DatabaseSystemDataSet4.UserAccount);

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            tbxUsername.Text = "";
            tbxPassword.Text = "";
            tbxEmail.Text = "";
            tbxUserLevel.Text = "";
        }
    }
}
